//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.cpcphone.abtestcenter;

import android.content.Context;
import android.support.annotation.WorkerThread;

import com.cpcphone.abtestcenter.exception.ParamException;
import com.cpcphone.abtestcenter.sdk.OnlineConfigAgent;
import com.gau.utils.net.request.THttpRequest;

import java.net.URISyntaxException;

import org.json.JSONException;
import org.json.JSONObject;

public class AbtestCenterService {

    private int[] sid;
    private int cid;
    private int cid2;
    private int cversion;
    private String local;
    private String utmSource;
    private int entrance;
    private int cdays;
    private int isupgrade;
    private Context mContext;
    private String userFrom;

    private AbtestCenterService(AbtestCenterService.Builder builder) {
        this.utmSource = "";
        this.userFrom = "";
        this.sid = builder.sid;
        this.cid = builder.cid;
        this.cid2 = builder.cid2;
        this.cversion = builder.cversion;
        this.local = builder.local;
        this.utmSource = builder.utmSource;
        this.entrance = builder.entrance;
        this.cdays = builder.cdays;
        this.isupgrade = builder.isupgrade;
        this.mContext = builder.mContext;
        this.userFrom = builder.userFrom;
    }

    public String getSid() {
        return String.valueOf(sid);
    }

    public int getCid() {
        return this.cid;
    }

    public int getCid2() {
        return this.cid2;
    }

    public int getCversion() {
        return this.cversion;
    }

    public String getLocal() {
        return this.local;
    }

    public String getUtmSource() {
        return this.utmSource;
    }

    public int getEntrance() {
        return this.entrance;
    }

    public int getCdays() {
        return this.cdays;
    }

    public String getUserFrom() {
        return this.userFrom;
    }

    public String getUrl() {
        return "";
    }

    public int getIsupgrade() {
        return this.isupgrade;
    }

    public void send(final AbtestCenterService.ResultCallback resultCallback) throws ParamException {
        OnlineConfigAgent.getInstance(mContext).start(cdays, resultCallback);
    }

    @WorkerThread
    public String sendSyn() throws ParamException, URISyntaxException {
        return  OnlineConfigAgent.getInstance(mContext).getResult();
    }

    public static void enableLog(boolean enable) {
    }

    public static void retentionStatics(Context context, int cid2, int sid, int abtestId, int filterId) {
    }

    public static void retentionStatics(Context context, int cid2, int[] sids, int[] abtestIds, int[] filterIds) {
    }

    public static void destroy(Context context) {
    }

    public static class Builder {
        private int[] sid;
        private int cid;
        private int cid2;
        private int cversion;
        private String local;
        private String utmSource;
        private int entrance;
        private int cdays;
        private int isupgrade;
        private String aid;
        private Context mContext;
        private String userFrom = "";
        private boolean isSafe;

        public Builder() {
        }

        public AbtestCenterService.Builder sid(int[] sid) {
            this.sid = sid;
            return this;
        }

        public AbtestCenterService.Builder cid(int cid) {
            this.cid = cid;
            return this;
        }

        public AbtestCenterService.Builder cid2(int cid2) {
            this.cid2 = cid2;
            return this;
        }

        public AbtestCenterService.Builder isSafe(boolean isSafe) {
            this.isSafe = isSafe;
            return this;
        }

        public AbtestCenterService.Builder cversion(int cversion) {
            this.cversion = cversion;
            return this;
        }

        public AbtestCenterService.Builder local(String local) {
            this.local = local.trim();
            return this;
        }

        public AbtestCenterService.Builder utm_source(String utm_source) {
            this.utmSource = utm_source.trim();
            return this;
        }

        public AbtestCenterService.Builder user_from(int user_from) {
            this.userFrom = user_from + "";
            return this;
        }

        public AbtestCenterService.Builder entrance(AbtestCenterService.Builder.Entrance en) {
            switch(en) {
                case MAIN_PACKAGE:
                    this.entrance = 1;
                    break;
                case THEME:
                    this.entrance = 2;
                    break;
                case TEST:
                    this.entrance = 999;
            }

            return this;
        }

        public AbtestCenterService.Builder cdays(int cdays) {
            this.cdays = cdays;
            return this;
        }

        public AbtestCenterService.Builder aid(String aid) {
            this.aid = aid.trim();
            return this;
        }

        public AbtestCenterService.Builder isupgrade(int isupgrade) {
            this.isupgrade = isupgrade;
            return this;
        }

        public AbtestCenterService build(Context context) {
            this.mContext = context;
            return new AbtestCenterService(this);
        }

        public static enum Entrance {
            MAIN_PACKAGE,
            THEME,
            TEST;

            private Entrance() {
            }
        }
    }

    public interface ResultCallback {
        void onResponse(String var1);

        void onException(THttpRequest var1, String var2, int var3);

        void onException(THttpRequest var1, int var2);
    }
}
